# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Dict, Union, List
from fastapi import APIRouter, Depends, Request
from hypertext import R, response_json
from apps.api.schemas import index_schema as schema
from apps.api.service.index_service import IndexService


router = APIRouter(prefix="/index", tags=["公共接口"])


@router.get("/config", summary="全局配置", response_model=R[schema.ConfigVo])
@response_json
async def config():
    return await IndexService.config()


@router.get("/models", summary="计费模型",
            response_model=R[Dict[str, Union[List[schema.AiModelsVo], List[schema.AiBroadcast]]]])
@response_json
async def models():
    return await IndexService.models()


@router.get("/diy", summary="装修数据", response_model=R[dict])
@response_json
async def diy(scene: int):
    return await IndexService.diy(scene)


@router.get("/monitor", summary="消息监听", response_model=R[schema.MonitorVo])
@response_json
async def monitor(request: Request):
    user_id: int = int(request.state.user_id)
    return await IndexService.monitor(user_id)


@router.get("/policy", summary="协议政策", response_model=R[schema.PolicyVo])
@response_json
async def policy(params: schema.QueryPolicyIn = Depends()):
    return await IndexService.policy(params.type)


@router.post("/send_sms", summary="发送短信", response_model=R)
@response_json
async def send_sms(params: schema.SendSmsIn):
    return await IndexService.send_sms(params.scene, params.mobile)


@router.post("/send_email", summary="发送邮件", response_model=R)
@response_json
async def send_email(params: schema.SendEmailIn):
    return await IndexService.send_email(params.scene, params.email)
